package com.xth8013.as.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by tianhua.xie on 2018/6/6 16:48.
 */
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
    @Autowired
    AuthenticationInterceptor authenticationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/**/assets/**","/**/css/**","/**/easyui_1.5/**","/**/layer/**","/**/script/**","/**/fonts/*","/**/*.css","/**/*.js","/**/*.png","/**/*.gif","/**/*.jpg","/**/*.jpeg","/image_inf/**","/**/*login*","/**/*Login*");
        super.addInterceptors(registry);
    }
}
